package com.gljr.exam.dao;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import com.gljr.exam.domain.InviteCode;

@Transactional(readOnly = true)
public interface InviteCodeRepository extends PagingAndSortingRepository<InviteCode, Long> {

	// User findByUsernameIgnoreCase(String username);
	// User save(String username ,String password);

	@Query("SELECT isBoolean FROM InviteCode WHERE inviteCode = ?1")
	Boolean getIfInviteCodeisBoolean(String inviteCode);

	@Modifying
	@Transactional
	@Query("UPDATE InviteCode SET isBoolean = ?3 ,username = ?2 WHERE inviteCode = ?1") // 设置验证码是否失效
	void setInviteCodeStatus(String inviteCode, String username, Boolean boolean1);

	InviteCode findByInviteCode(String string);

	InviteCode findInviteCodeByInviteCode(String string);

}
